//
//  ClassClusterViewController.m
//
//  Created by 周成龙
//

#import "ClassClusterViewController.h"

// ---------------------------- 父类
@implementation ClusterEmployee

+ (ClusterEmployee *)employeeWithType:(ClusterEmployeeType)type {
    switch (type) {
        case ClusterEmployeeTypeDeveloper: {
            return [ClusterEmployeeDeveloper new];
        }
            break;
        
        case ClusterEmployeeTypeDesigner: {
                return [ClusterEmployeeDesigner new];
            }
            break;

        case ClusterEmployeeTypeFinance: {
            return [ClusterEmployeeFinance new];
        }
        break;
    }
}

- (void)doADayWork {
    NSLog(@"----不执行");
}

@end



// ---------------------------- 子类
@implementation ClusterEmployeeDeveloper
- (void)doADayWork {
    NSLog(@"coding");
}
@end
@implementation ClusterEmployeeDesigner
- (void)doADayWork {
    NSLog(@"designer");
}
@end
@implementation ClusterEmployeeFinance
- (void)doADayWork {
    NSLog(@"finance");
}
@end



// ---------------------------- 控制器

@interface ClassClusterViewController ()

@end

@implementation ClassClusterViewController
#pragma mark - LifeCycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self test1];
}

- (void)test1 {
    ClusterEmployee *c1 = [ClusterEmployee employeeWithType:ClusterEmployeeTypeDeveloper];
    [c1 doADayWork];
    
    ClusterEmployee *c2 = [ClusterEmployee employeeWithType:ClusterEmployeeTypeDesigner];
    [c2 doADayWork];
    
    ClusterEmployee *c3 = [ClusterEmployee employeeWithType:ClusterEmployeeTypeFinance];
    [c3 doADayWork];
}


@end
